var path = require('path');
var HtmlWebpackPLugin = require('html-webpack-plugin');
var webpack = require('webpack');
module.exports = {
  entry:{
    index:"./src/index.js",
  },
  output:{
    filename:"[name].bundle.js",
    path:path.resolve(__dirname,"dist"),
    // publicPath:'/'
  },
  devtool : '#source-map',
  module:{ 
    rules:[
      {test:/\.css$/,use:['style-loader','css-loader']},
      {test:/\.less$/,use:['style-loader','css-loader', 'less-loader?sourceMap']},
      {test:/\.scss$/,use:['style-loader','css-loader', 'sass-loader?sourceMap']},
      {test:/\.js$/,use: {
        loader: 'babel-loader',
        options: {
          presets: ['es2015','stage-3'],
          plugins: [require('babel-plugin-transform-object-rest-spread')]
        }
        },exclude:'/home/zsk/gitarea/mini-frontend/node_modules'
      },
      {test:/\.(jpg|png|gif|svg)$/,use:['file-loader']},
      {test:/\.(woff|woff2|eot|ttf|otf)/, use:['file-loader']},
      {test:/\.ejs$/, use:['ejs-loader']},
      {test:/\.html$/, use:['html-withimg-loader']}
    ]
  },

  plugins:[
    new webpack.optimize.CommonsChunkPlugin({name:'common',filename:'common.js'}),//针对所有的入口
    new HtmlWebpackPLugin({filename:'index.html',template:'src/template/index.html',hash:false,chunks:['index','common']}),//游戏选择页面
    new webpack.HotModuleReplacementPlugin() //热模块替换
  ],
  devServer:{
    // colors:true,
    port:8080,
    inline:true,
    contentBase:'dist',
    compress:true,
    hot:true
  }
}